﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using BALayer;

namespace PGBT
{
    public partial class DanhMucDatHang : Form
    {
        private GiaoDich db = null;
        private DataSet dsDatHang = null;

        public DanhMucDatHang()
        {
            InitializeComponent();
        }

        private void DanhMucDatHang_Load(object sender, EventArgs e)
        {
            db = new GiaoDich();
            dsDatHang = db.DanhSachDatHang();
            cbMaDatHang.DataSource = dsDatHang.Tables[0];
            cbMaDatHang.DisplayMember = "madathang";
        }

        private void cbMaDatHang_SelectedIndexChanged(object sender, EventArgs e)
        {
            txtTenNCC.Text = dsDatHang.Tables[0].Rows[cbMaDatHang.SelectedIndex].ItemArray[2].ToString();
            txtNgayDat.Text = dsDatHang.Tables[0].Rows[cbMaDatHang.SelectedIndex].ItemArray[3].ToString();

            int madh = Convert.ToInt32(dsDatHang.Tables[0].Rows[cbMaDatHang.SelectedIndex].ItemArray[0].ToString());
            dgvHangHoa.DataSource = db.ChiTietDatHang(madh).Tables[0];
            dgvHangHoa.AutoResizeColumns();
        }
    }
}
